package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Arrays;

import jdbc.jdbcConn;

public class JdbcBatch extends jdbcConn {

	public static void main(String[] args) {
         
	Connection conn =null;
	PreparedStatement ps=null;		
        try {
        	conn=getConnection();
			ps=conn.prepareStatement("insert into qingke.player(name,username,userpassword) values(?,?,?)");
			
			for(int i=1;i<=18;i++){
				ps.setString(1, "xy"+i);
				ps.setString(2, "cxy"+i);
				ps.setString(3, "13579");
				ps.addBatch();
			}
			int[] results =ps.executeBatch();
			
			System.out.println("results="+Arrays.toString(results));
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
 	}
}